import request from '@/utils/request';

// 获取订单列表
export function getOrders(params) {
    return request({
        url: '/admin/orders',
        method: 'get',
        params
    });
}

// 获取订单详情
export function getOrderDetail(id) {
    return request({
        url: `/admin/orders/${id}`,
        method: 'get'
    });
}

// 发货
export function shipOrder(data) {
    return request({
        url: `/admin/orders/${data.orderId}/ship`,
        method: 'post',
        data
    });
}

// 确认自提订单准备完成
export function confirmReadyForPickup(id) {
    return request({
        url: `/admin/orders/${id}/ready-for-pickup`,
        method: 'post'
    });
}

// 确认同城配送订单准备完成
export function confirmLocalOrderReady(id) {
    return request({
        url: `/admin/orders/${id}/ready-for-delivery`,
        method: 'post'
    });
}

// 自动分配骑手
export function assignRider(id) {
    return request({
        url: `/admin/orders/${id}/assign-rider`,
        method: 'post'
    });
}

// 手动分配骑手
export function manualAssignRider(orderId, riderId) {
    return request({
        url: `/admin/orders/${orderId}/manual-assign-rider`,
        method: 'post',
        data: { riderId }
    });
}

// 获取可用骑手列表
export function getAvailableRiders() {
    return request({
        url: '/admin/riders/available',
        method: 'get'
    });
}

export default {
    getOrders,
    getOrderDetail,
    shipOrder,
    confirmReadyForPickup,
    confirmLocalOrderReady,
    assignRider,
    manualAssignRider,
    getAvailableRiders
}; 